<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jq/jquery.js"></script>
</head>
<body>
<center>
	省:<select id="sheng">
		<option value="">请选择</option>
		<c:forEach items="${shengList }" var="testPojo1">
			<option value="${testPojo1.sid }" <c:if test="${testPojo1.sid==testPojo.sid }">selected="selected"</c:if> >${testPojo1.name }</option>
		</c:forEach>
	</select>
	市:<select id="shi">
		<option value="">请选择</option>
	</select>
</center>
</body>
<script type="text/javascript">
	$(function () {
		$("#sheng").change(function () {
			$.ajax({
				url:"TestContrl/queryShi.do",
				data:{"sid":$("#sheng").val()},
				type:"post",
				dataType:"json",
				success:function(date){
					for (var i in date) {
                        var jsonObj =date[i];  
                        var optionstring = "";
                        for (var j = 0; j < jsonObj.length; j++) { 
                            optionstring += "<option value=\""  + jsonObj[j].shid + "\">" + jsonObj[j].name + "</option>";  
                            $("#shi").html("<option value=''>请选择</option>"+ optionstring);
                        }  
                    }
				},
				error:function(){
					alert("出现异常");
				}
			});
// 			location.href="TestContrl/queryShi.do?sid="+$("#sheng").val();
		});
	});
</script>
</html>